 /**
 * Description: 生成项目业务实现类
 * Copyright:Copyright 2018 nfky.com. All rights reserved
 * @author:xk
 * @since:0.0.1
 * Create at:2018-01-18 下午 14:31:30
 *  
 * Modification History:
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2018-01-18   xk       0.0.1     Initial
 */
package com.metro.generator.gen.service.impl;

import com.metro.core.dao.IMapper;
import com.metro.core.service.BaseServiceSupport;
import com.metro.core.service.ServiceException;
import com.metro.core.vo.ResultCode;
import com.metro.core.vo.inf.IResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.metro.generator.gen.mapper.IGenProjectMapper;
import com.metro.generator.gen.service.inf.IGenProjectService;
import com.metro.generator.gen.beans.vo.GenProject;

 /**
 * 生成项目业务实现类<br>
 *
 * @author xk
 * @since [0.0.1]
 * @version [0.0.1, 2018-01-18]
 */
@Service("genProjectService")
public class GenProjectService extends BaseServiceSupport<GenProject> implements IGenProjectService{
    //生成项目Mapper
    @Autowired
    private IGenProjectMapper genProjectMapper;

    @Override
    public IMapper getMapper() {
        return genProjectMapper;
    }

    @Override
    public IResult save(GenProject entity) {
        try {
            genProjectMapper.save(entity);
            return ResultCode.SUCCESS;
        } catch (Exception e) {
            log.error("新增生成项目失败", e);
            throw new ServiceException(ResultCode.ERROR);
        }
    }

    @Override
    public IResult update(GenProject entity) {
        try {
            genProjectMapper.update(entity);
            return ResultCode.SUCCESS;
        } catch (Exception e) {
            log.error("修改生成项目失败", e);
            throw new ServiceException(ResultCode.ERROR);
        }
    }

    @Override
    public IResult delete(Long id) {
        try {
            genProjectMapper.delete(id);
            return ResultCode.SUCCESS;
        } catch (Exception e) {
            log.error("删除失败", e);
            throw new ServiceException(ResultCode.ERROR);
        }
    }

    @Override
    public IResult deleteByIds(String ids) {
        try {
            genProjectMapper.deleteByIds(ids);
            return ResultCode.SUCCESS;
        } catch (Exception e) {
            log.error("删除失败", e);
            throw new ServiceException(ResultCode.ERROR);
        }
    }
}